import { useUserStore } from '@/store'

// 权限校验
export const checkAuth = (permission?: string) => {
  //return true
  // 权限数据不完善，暂时不进行权限判断
  const userStore = useUserStore()
  return (
    userStore.nodePermissionMap.get(permission as string) ||
    userStore.permissionAuth(permission as string)
  )
}

interface OptionsItem {
  label: string
  value: number | string | boolean
}
export const getOptionsLabelFn =
  (options: OptionsItem[], handler = (v: any) => v) =>
  (value: OptionsItem['value']) => {
    const label = options.find((v) => v.value === handler(value))?.label || ''
    return String(label)
  }
